From d87addffb1181140cf5ba649655d4dcc853be259 Mon Sep 17 00:00:00 2001 From: "kaf24@localhost.localdomain" Date: Sat, 19 Aug 2006 17:07:54 +0100 Subject: [PATCH] [XEN] Clarify x86 hypercall ABI in public header comments. In particular: x86/64 *does* clobber its ragument registers (just like i386). This happens in debug builds, and if a continuation is created. Signed-off-by: Keir Fraser --- xen/include/public/arch-x86_32.h | 22 +++++++++++++++++++--- xen/include/public/arch-x86_64.h | 22 +++++++++++++++++++--- xen/include/public/xen.h | 10 +--------- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/xen/include/public/arch-x86_32.h b/xen/include/public/arch-x86_32.h index bb6eddcdde..2d717f0cc0 100644 --- a/xen/include/public/arch-x86_32.h +++ b/xen/include/public/arch-x86_32.h @@ -9,6 +9,25 @@ #ifndef __XEN_PUBLIC_ARCH_X86_32_H__ #define __XEN_PUBLIC_ARCH_X86_32_H__ +/* + * Hypercall interface: + * Input: %ebx, %ecx, %edx, %esi, %edi (arguments 1-5) + * Output: %eax + * Access is via hypercall page (set up by guest loader or via a Xen MSR): + * call hypercall_page + hypercall-number * 32 + * Clobbered: Argument registers (e.g., 2-arg hypercall clobbers %ebx,%ecx) + */ + +#if __XEN_INTERFACE_VERSION__ < 0x00030203 +/* + * Legacy hypercall interface: + * As above, except the entry sequence to the hypervisor is: + * mov $hypercall-number*32,%eax ; int $0x82 + */ +#define TRAP_INSTR "int $0x82" +#endif + + /* Structural guest handles introduced in 0x00030201. */ #if __XEN_INTERFACE_VERSION__ >= 0x00030201 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \ @@ -71,9 +90,6 @@ DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); #define FLAT_USER_DS FLAT_RING3_DS #define FLAT_USER_SS FLAT_RING3_SS -/* And the trap vector is... */ -#define TRAP_INSTR "int $0x82" - /* * Virtual addresses beyond this are not modifiable by guest OSes. The * machine->physical mapping table starts at this address, read-only. diff --git a/xen/include/public/arch-x86_64.h b/xen/include/public/arch-x86_64.h index ebfc291808..2891cfa29e 100644 --- a/xen/include/public/arch-x86_64.h +++ b/xen/include/public/arch-x86_64.h @@ -9,6 +9,25 @@ #ifndef __XEN_PUBLIC_ARCH_X86_64_H__ #define __XEN_PUBLIC_ARCH_X86_64_H__ +/* + * Hypercall interface: + * Input: %rdi, %rsi, %rdx, %r10, %r8 (arguments 1-5) + * Output: %rax + * Access is via hypercall page (set up by guest loader or via a Xen MSR): + * call hypercall_page + hypercall-number * 32 + * Clobbered: argument registers (e.g., 2-arg hypercall clobbers %rdi,%rsi) + */ + +#if __XEN_INTERFACE_VERSION__ < 0x00030203 +/* + * Legacy hypercall interface: + * As above, except the entry sequence to the hypervisor is: + * mov $hypercall-number*32,%eax ; syscall + * Clobbered: %rcx, %r11, argument registers (as above) + */ +#define TRAP_INSTR "syscall" +#endif + /* Structural guest handles introduced in 0x00030201. */ #if __XEN_INTERFACE_VERSION__ >= 0x00030201 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \ @@ -86,9 +105,6 @@ DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); #define FLAT_USER_SS32 FLAT_RING3_SS32 #define FLAT_USER_SS FLAT_USER_SS64 -/* And the trap vector is... */ -#define TRAP_INSTR "syscall" - #define __HYPERVISOR_VIRT_START 0xFFFF800000000000 #define __HYPERVISOR_VIRT_END 0xFFFF880000000000 #define __MACH2PHYS_VIRT_START 0xFFFF800000000000 diff --git a/xen/include/public/xen.h b/xen/include/public/xen.h index 17f7c69c38..b06f215174 100644 --- a/xen/include/public/xen.h +++ b/xen/include/public/xen.h @@ -24,17 +24,9 @@ #endif /* - * XEN "SYSTEM CALLS" (a.k.a. HYPERCALLS). + * HYPERCALLS */ -/* - * x86_32: EAX = vector; EBX, ECX, EDX, ESI, EDI = args 1, 2, 3, 4, 5. - * EAX = return value - * (argument registers may be clobbered on return) - * x86_64: RAX = vector; RDI, RSI, RDX, R10, R8, R9 = args 1, 2, 3, 4, 5, 6. - * RAX = return value - * (argument registers not clobbered on return; RCX, R11 are) - */ #define __HYPERVISOR_set_trap_table 0 #define __HYPERVISOR_mmu_update 1 #define __HYPERVISOR_set_gdt 2 -- 2.30.2